package cn.smbms.service.bill;

import java.util.List;

import cn.smbms.dao.bill.BillMapper;
import cn.smbms.pojo.Bill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BillServiceImpl implements BillService {


	@Autowired
	private BillMapper billMapper;
	
	@Override
	public boolean add(Bill bill) {
		boolean flag = false;
		if(billMapper.add(bill) > 0) flag = true;
		return flag;
	}

	@Override
	public List<Bill> getBillList(Bill bill, Integer currentPageNo,int pageSize) {
		return billMapper.getBillList(bill,(currentPageNo-1)*pageSize,pageSize);
	}

	@Override
	public boolean deleteBillById(String delId) {
		boolean flag = false;
			if(billMapper.deleteBillById(delId) > 0) flag = true;
		return flag;
	}

	@Override
	public Bill getBillById(String id) {
		// TODO Auto-generated method stub
		Bill bill = null;
		try{
			
			bill = billMapper.getBillById(id);
		}catch (Exception e) {
			e.printStackTrace();
			bill = null;
		}finally{
		
		}
		return bill;
	}

	@Override
	public boolean modify(Bill bill) {
		// TODO Auto-generated method stub
	
		boolean flag = false;
		try {
			
			if(billMapper.modify(bill) > 0)
				flag = true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
		
		}
		return flag;
	}

	@Override
	public int getCount(String queryProductName, String queryProviderId, String queryIsPayment) {
		return billMapper.getCount(queryProductName,queryProviderId,queryIsPayment);
	}

}
